CFLAGS= -g -std=gnu99
CFLAGS += -I./ -I./mlnredis_lib
CC=gcc
OBJS_SAMPLES = mln_sample_filter.o mln_samples.o 
OBJS=  main.o $(OBJS_SAMPLES)

LDFLAGS += -L./ -L./mlnredis_lib
LDFLAGS += -lhiredis -lssl -lcrypto -lpthread -lmlnredis
DEPDIR = .deps
TARGET = redistest
LIB_DIR = mlnredis_lib

all :	$(DEPDIR) subdir $(TARGET)

$(DEPDIR):
	+@[ -d $@ ] || mkdir -p $@


subdir:
	@for i in $(LIB_DIR); do \
        if [ -f "$$i/Makefile" ]; then \
            (cd $$i && $(MAKE) all) || exit 1; \
        fi; \
    done

$(TARGET): $(OBJS)
	$(CC) -o $(TARGET) $(OBJS) -lm $(LDFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@ -MD -MF $(DEPDIR)/$(<:.c=.d)

clean:
	rm -rf *.o $(DEPDIR) $(TARGET) $(LIB_TARGET) 
	@for i in $(LIB_DIR); do \
        if [ -f "$$i/Makefile" ]; then \
            (cd $$i && $(MAKE) clean) || exit 1; \
        fi; \
    done


-include $(DEPDIR)/*.d

